import * as survey from "../../api/survey";

Page({
    data: {
        currentPage:1,
        list:[],
        currentPage:1,
        hasNextPage:true,
        total:"",

        countDate:"",
        townCode:"",
        surveyNum:""
    },
    onLoad(option){

        this.setData({
            countDate:option.countDate,
            townCode:option.townCode,
            surveyNum:option.surveyNum
        })

        this.get_order_list();
    },
    get_order_list(){
        survey.surveyList({
            currentPage:this.data.currentPage,
            pageSize:10,
            countDate: this.data.countDate,
            townCode:this.data.townCode
        })
        .then((res)=>{

            this.setData({
                list:this.data.currentPage == 1 ? res.list :[...this.data.list, ...res.list],
                hasNextPage:res.hasNextPage,
                total:res.total
            })
        })
    },
    handle_record_detail(e){
        let { item } = e.currentTarget.dataset;
        wx.navigateTo({
            url: '/pages/record-detail/record-detail?id='+item.id
        });
    },
    onReachBottom(){
        if(this.data.hasNextPage){
            this.setData({
                currentPage: ++this.data.currentPage
            })
            this.get_order_list();
        }
    }
})
